﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class common_Root : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        bool haveBeenLogin = false;
        Object userId = Session["userId"];
        userId_catption.Visible = false;
        this.userId.Visible = false;
        userName_catption.Visible = false;
        this.userName.Visible = false;

        if (userId != null)
        {

            if (!Util.IsBlank((String)userId))
            {
                userId_catption.Text = "User ID:";
                userId_catption.Visible = true;
                this.userId.Text = (String)userId;
                this.userId.Visible = true;
                haveBeenLogin = true;
            }
            else
            {
                userId_catption.Visible = false;
                this.userId.Visible = false;
            }

        }
       
           
       

        Object userName = Session["userName"];
        if (userName != null)
        {
            
            if (!Util.IsBlank((String)userName))
            {
                userName_catption.Text = "Name:";
                userName_catption.Visible = true;
                this.userName.Text = (String)userName;
                this.userName.Visible = true;
                haveBeenLogin = true;
            }
            else
            {
                userName_catption.Visible = false;
                this.userName.Visible = false;
            }

        }

        if (haveBeenLogin)
        {
            this.Logout.Visible = true;
        }
        else
        {
            this.Logout.Visible = false;
        }
        
    }
  
   
    protected void Logout_Click(object sender, EventArgs e)
    {
        Session.Clear();
        userId_catption.Visible = false;
        this.userId.Visible = false;
        userName_catption.Visible = false;
        this.userName.Visible = false;
        this.Logout.Visible = false;
        
        Response.Redirect("~/home.aspx");
    }
}
